package com.study.springannotation.beans;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.stereotype.Component;

/**
 * 
 * say something here
 * 
 * @author Jimmy.Qiu
 * 
 */
// @Component不带参数bean name自动生成，生成规则：类名 + 首字母大写
@Component
public class SayHello implements ISay {
	public void say(String who) {
		System.out.println(who + " say: Hello");
	}

	/**
	 * 类似于xml中的 init-method配置，不同的是@PostConstruct可以有多个 通常是针对一些资源的获取和释放操作
	 */
	@PostConstruct
	public void init1() {
		System.out.println("SayHello init1");
	}

	@PostConstruct
	public void init2() {
		System.out.println("SayHello init2");
	}

	@PreDestroy
	public void destroy1() {
		System.out.println("SayHello destroy1");
	}

	@PreDestroy
	public void destroy2() {
		System.out.println("SayHello destroy2");
	}

	@Override
	protected void finalize() throws Throwable {
		System.out.println("SayHello finalize");
		super.finalize();
	}
}
